package dlg.code.composite.service.filter;

import dlg.code.composite.service.IFilter;

public class AgeFilter implements IFilter {

    private final Integer start;
    private final Integer end;
    private final String type;

    public AgeFilter(Integer start, Integer end, String type) {
        this.start = start;
        this.end = end;
        this.type = type;
    }

    @Override
    public boolean predict(String in, String out) {
        switch (type) {
            case "lt": {
                return Integer.parseInt(out) < start;
            }
            case "gte": {
                return Integer.parseInt(out) > end;
            }
            case "lgt": {
                return Integer.parseInt(out) < end && Integer.parseInt(out) > start;
            }
            default:
        }
        return false;
    }
}
